package com.example.natatorium_management.contorller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.natatorium_management.entity.Reserve;
import com.example.natatorium_management.result.restful.R;
import com.example.natatorium_management.service.ReserveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Reserve")
public class ReserveController {
    @Autowired
    ReserveService reserveService;

    /**
     * 分页
     * @param current 1
     * @param size 1
     * @return 1
     */
    @GetMapping("/queryPage")
    public R<IPage<Reserve>> queryPage(int current, int size){
        return reserveService.queryPage(current,size);
    }

    /**
     * 新增预定
     * @param reserve 1
     * @return 1
     */
    @PostMapping("/addReserve")
    public R<Reserve> addReserve(@RequestBody Reserve reserve){
        return reserveService.addReserve(reserve);
    }

    /**
     * 删除预定订单
     * @param reserveId 1
     * @return 1
     */
    @DeleteMapping("/deleteReserveById/{reserveId}")
    public R<Reserve> deleteReserveById(@PathVariable("reserveId") int reserveId){
        return reserveService.deleteReserveById(reserveId);
    }

    /**
     * 根据id查询
     * @param reserveId 1
     * @return 1
     */
    @GetMapping("/findReserveById/{reserveId}")
    public R<Reserve> findReserveById(@PathVariable("reserveId")int reserveId){
        return reserveService.findReserveById(reserveId);
    }

    /**
     * 查询预定
     * @param reserve 1
     * @param current 1
     * @param size 1
     * @return 1
     */
    @PostMapping("/findReserve")
    public R<IPage<Reserve>> findReserve(@RequestBody Reserve reserve,@RequestParam int current,@RequestParam int size){
        return reserveService.findReserve(reserve,current,size);
    }

    @PutMapping("/updateReserve")
    public R<Reserve> updateReserve(@RequestBody Reserve reserve){
        return reserveService.updateReserve(reserve);
    }
}
